<extend name="Public/base" />
<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>视频列表</h2>
    </div>
    <div> PS: 操作列 比赛后面带(*) 表示已经归入一场比赛中, 点击可进入比赛视频编辑</div>
    <br/>
    <div class="cf">
        <div class="fl">
            <!-- <a class="btn" href="{:U('add?game_id='.$game_id)}">新 增</a> -->
            <button class="btn btn-default ajax-post" url="{:U('changeStatus',array('method'=>'resume'))}" target-form="ids">启 用</button>
            <button class="btn btn-default  ajax-post" url="{:U('changeStatus',array('method'=>'forbid'))}" target-form="ids">禁 用</button>
            <button class="btn btn-default ajax-post" url="{:U('recommend')}" target-form="ids">推 荐</button>
            <button class="btn btn-default ajax-post" url="{:U('undo_recommend')}" target-form="ids">取消推荐</button>
            <button class="btn btn-danger ajax-post confirm" url="{:U('del')}" target-form="ids">删 除</button>
        </div>
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <select name="game" style="float:left;">
                    <option value="">--游戏--</option>
                    <volist name="games" id="g">
                        <option value="{$key}" <eq name="key" value="$game"> selected</eq>>{$g}</option>
                    </volist>
                </select>
                <input type="text" name="title" class="search-input" value="{:I('title')}" placeholder="请输入标题">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="row-selected row-selected">
                        <input class="check-all" type="checkbox" />
                    </th>
                    <th class="">缩略图</th>
                    <th class="">视频名称</th>
                    <th class="">游戏</th>
                    <th class="">视频地址</th>
                    <th class="">预览视频</th>
                    <th class="">时长</th>
                    <th class="">上传时间</th>
                    <!--<th class="">描述</th>-->
                    <th class="">状态</th>
                    <th class="">推荐</th>
                    <th class="">操作</th>
                </tr>
            </thead>
            <tbody>
                <notempty name="_list">
                    <volist name="_list" id="vo">
                        <tr>
                            <td width="2%">
                                <input class="ids" type="checkbox" name="id[]" value="{$vo.id}" />
                            </td>
                            <td width="15%">
                                <div class="upload-img-box">
                                    <notempty name="vo.thumb">
                                        <div class="upload-pre-item"><img src="__ROOT__{$vo.thumb}" /></div>
                                    </notempty>
                                </div>
                            </td>
                            <td width="20%">{$vo.full_title|default=$vo['title']|htmlspecialchars_decode} </td>
                            <td width="10%">{$games[$vo['game_id']]}</td>
                            <td>
                                <notempty name="vo.uri">
                                    <a target="_blank" class="js-pre-video" href="{:C('VIDEO_UPLOAD.uri_path')}{$vo.uri}"><i class="glyphicon glyphicon-play-circle"></i> 视频预览</a>
                                </notempty>
                            </td>
                            <td>
                                <notempty name="vo.pre_uri">
                                    <a target="_blank" class="js-pre-video" href="{:C('VIDEO_UPLOAD.uri_path')}{$vo.pre_uri}"><i class="glyphicon glyphicon-play-circle"></i> 视频预览</a>
                                </notempty>
                            </td>
                            <td>
                                {$vo.time|default=0}
                            </td>
                            <td>
                                {$vo.create_time|date="Y-m-d",###}
                            </td>
                            <!-- <td>{$vo.detail}</td> -->
                            <td>
                                {$vo.status_text}
                            </td>
                            <td>
                                {$vo.recommend_text}
                            </td>
                            <td>
                                <a class="btn btn-default btn-xs" title="编辑" href="{:U('edit?game_id='.$game_id.'&id='.$vo['id'])}"><i class="glyphicon glyphicon-pencil"></i></a>
                                <a href="{:U('setTopic?id='.$vo['id'])}">栏目</a>
                                <a href="{:U('setMatch?id='.$vo['id'])}">比赛<notempty name="vo.match_race_id"><a href="{:U('Match/video?id='.$vo['match_race_id'])}">(*)</a></notempty></a>
                <eq name="vo.recommend" value="1">
                    <a href="{:U('undo_recommend?id='.$vo['id'])}" class="ajax-get">取消推荐</a>
                    <else />
                    <a href="{:U('recommend?id='.$vo['id'])}" class="ajax-get">推荐</a>
                </eq>
                <a href="{:U('Recommend/add?video_id='.$vo['id'])}" class="confirm ajax-get">上头条</a>
                <a href="{:U('del?id='.$vo['id'])}" class="confirm ajax-get btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
                </td>
                </tr>
                </volist>
                <else/>
                <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
                </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">{$_page}</div>
    <div id="video-pre">
        <video controls="controls" autoplay="autoplay"></video>
    </div>
</block>
<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script type="text/javascript">
    //搜索功能
    $("#search").click(function() {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');

        var game = $('.search-form').find('select').serialize();
        game = game.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        game = game.replace(/^&/g, '');

        if (url.indexOf('?') > 0) {
            url += '&' + query + '&' + game;
        } else {
            url += '?' + query + '&' + game;
        }
        window.location.href = url;
    });
    //回车搜索
    $(".search-input").keyup(function(e) {
        if (e.keyCode === 13) {
            $("#search").click();
            return false;
        }
    });
    //导航高亮
    highlight_subnav('{:U('
        index ')}');
    //视频预览
    $('.js-pre-video').on('click', function() {
        var url = $(this).attr('href');
        // alert(url);
        $('#video-pre').addClass('show').find('video').attr('src', url);
        return false;
    })
    $('video').click(function(e) {
        return false;
    })
    $('#video-pre').click(function() {
        $(this).find('video').attr('src', '');
        $(this).removeClass('show');
    })
    </script>
</block>
